<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>发布自定义资源</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../static/layui/css/layui.css"  media="all">
  <script src="../static/jquery-3.5.1.min.js"></script>
  <script src="../static/js.cookie.min.js"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
          
              
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>发布自定义资源</legend>
</fieldset>
 
<form class="layui-form layui-form-pane" action="" lay-filter="example">
	
  
  <div class="layui-form-item">
	<div class="layui-inline">
		<label class="layui-form-label">资源名称</label>
		<div class="layui-input-inline">
		  <input type="text" name="itemsName" lay-verify="required" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
		</div>
	</div>
  </div>
  <div class="layui-form-item">
	<div class="layui-inline">
		<label class="layui-form-label">资源图片</label>
		<div class="layui-input-inline">
		  <input type="text"  name="itemsPicture" autocomplete="off" class="layui-input">
		</div>
	</div>
  </div>  
  
   <div class="layui-form-item">
     <label class="layui-form-label">资源类型</label>
     <div class="layui-input-block">
       <input type="radio" name="itemsType" value="公共资源" title="公共资源" checked="">
       <input type="radio" name="itemsType" value="个人资源" title="个人资源">
       <input type="radio" name="itemsType" value="个人能力" title="个人能力" >
     </div>
   </div>
<!-- <div class="layui-form-item" >
    <div class="layui-inline">
      <label class="layui-form-label">资源类型</label>
      <div class="layui-input-inline">
        <input type="text" name="itemsType" lay-verify="required" placeholder="请输入物品类型" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div> -->

  
  <div class="layui-form-item">
  	<div class="layui-inline">
  		<label class="layui-form-label">单价</label>
  		<div class="layui-input-inline">
  		  <input type="text" name="itemsPrice"  placeholder="请输入资源单价" autocomplete="off" class="layui-input">
  		</div>
  	</div>
  </div>
  <div class="layui-form-item">
  	<div class="layui-inline">
  		<label class="layui-form-label">数量</label>
  		<div class="layui-input-inline">
  		  <input type="text" name="itemsMaxNum"  placeholder="请输入资源数量" autocomplete="off" class="layui-input">
  		</div>
  	</div>
  </div>
  
	  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">起始日期</label>
	      <div class="layui-input-inline">
	        <input type="text" class="layui-input" name="itemsStartTime" id="test1" placeholder="yyyy-MM-dd">
	      </div>
	    </div>
	    <div class="layui-inline">
	      <label class="layui-form-label">结束日期</label>
	      <div class="layui-input-inline">
	        <input type="text" class="layui-input" name="itemsEndTime" id="test1-1" placeholder="yyyy-MM-dd">
	      </div>
	    </div>
	  </div>
   
   
   <!-- <div class="layui-form-item" >
      <div class="layui-inline">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline">
          <input type="text" name="itemsPicture"  placeholder="请输入新学号" autocomplete="off" class="layui-input">
        </div>
      </div>
    </div> -->
	
	<div class="layui-form-item" >
	   <div class="layui-inline">
	     <label class="layui-form-label">备注</label>
	     <div class="layui-input-inline">
	       <input type="text" name="remark"  placeholder="请输入物品备注" autocomplete="off" class="layui-input">
	     </div>
	   </div>
	 </div>
	  
	
		
  <div class="layui-form-item">
      <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  
  
</form>
          
<script src="../static/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>

	
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  
  

  
  //监听提交
  form.on('submit(demo1)', function(data){
    layer.alert(JSON.stringify(data.field), {
      title: '最终的提交信息'
    })
	
	$.ajax({
	  xhrFields:{withCredentials: true},
	  type: 'POST',
	  url: "http://127.0.0.1:8000/api/v1/users/0/items/",
	  data: JSON.stringify(data.field),
	  dataType:"json",
	  success:function(data){
		  if(data.code==200){
			  layer.msg("发布成功",function(){
				  // window.location.href="http://127.0.0.1:8848/RSS/login.html".
			  })
		  }else{
			  layer.msg(data.msg);
		  }
	  }
	  
	});
	
    return false;
  });
 
  
  //表单取值
  layui.$('#LAY-component-form-getval').on('click', function(){
    var data = form.val('example');
    alert(JSON.stringify(data));
  });
  
});
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //常规用法
  laydate.render({
    elem: '#test1'
  });
  
  //国际版
  laydate.render({
    elem: '#test1-1'
    ,lang: 'en'
  });
  })
</script>

</body>
</html>   